const moment = require('moment');
const crypto = require('crypto')

// 1. 定义密钥
const secret_key = 'Kjwi769,$#'
// 2. 定义加密规则
const md5 = (pwd) => {
  return crypto.createHash('md5').update(pwd).digest('hex');
}
// 3. 定义加密函数
const getPassword = (content) => {
  return md5(`password=${content}&&secret_key=${secret_key}`)
}

exports.getPassword = getPassword
exports.relativeTime = time => moment(new Date(time * 1000)).fromNow();